#define _CRT_SECURE_NO_WARNING
#include<stdio.h>
#include<math.h>
int count(int num)
{
	int count = 0;
	while (num != 0)
	{
		num = num / 10;
		count++;
	}
	return count;
}
int menu(int num)
{
	int b = num;
	int n = count(num);
	int sum = 0;
	while (num != 0)
	{
		int digit = num % 10;
		sum += pow(digit, n);
		num /= 10;
	}
	return(sum == b);
}
int main()
{
	int i = 0;
	for (i = 0; i <= 100000; i++)
	{
		if (menu(i))
			printf("%d ", i);
	}
	return 0;
}